Skip to content

Conversation

prrace
Copy link
Contributor

@prrace prrace commented Oct 5, 2025

Specifying the behaviour of BufferedImage constructors for invalid dimensions is long overdue.

The behaviour for image types and sizes <= 0 is unchanged by this PR.
Also in many cases the behaviour for sizes that are too large is also unchanged.
In some cases, the behaviour is changed from "accidental" NegativeArraySizeException to a consistent IllegalArgumentException.

In no case is anything changed that would affect the possibility to construct a BufferedImage.

A test is provided to ensure the behaviour.

A CSR is provided too : https://bugs.openjdk.org/browse/JDK-8369155


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8369155 to be approved

Warning

 ⚠️ Found leading lowercase letter in issue title for 4617681: constructor of BufferedImage throws unexpected IllegalArgumentException

Issues

  • JDK-4617681: constructor of BufferedImage throws unexpected IllegalArgumentException (Bug - P4)
  • JDK-8369155: constructor of BufferedImage throws unexpected IllegalArgumentException (CSR)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27640/head:pull/27640
$ git checkout pull/27640

Update a local copy of the PR:
$ git checkout pull/27640
$ git pull https://git.openjdk.org/jdk.git pull/27640/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27640

View PR using the GUI difftool:
$ git pr show -t 27640

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27640.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 5, 2025

👋 Welcome back prr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 5, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title 4617681 4617681: constructor of BufferedImage throws unexpected IllegalArgumentException Oct 5, 2025
@openjdk openjdk bot added csr Pull request needs approved CSR before integration client [email protected] labels Oct 5, 2025
@openjdk
Copy link

openjdk bot commented Oct 5, 2025

@prrace The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 5, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 5, 2025

Webrevs

* not greater than zero.
* @throws IllegalArgumentException if the multiplication product of
* {@code width}, {@code height}, and the number of samples per pixel
* for the specified format exceeds the maximum length of a Java array.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems too strict. It is possible to implement a BufferedImage that splits its internal data into multiple surfaces/arrays. It might be better to phrase this as optional:
“for the specified format exceeds the maximum supported length”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] csr Pull request needs approved CSR before integration rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants